$(function(){
//	发送到手机
$('.code1').click(function(){
$.ajax({
 type: 'GET',
 url:"" + mobile, //即上面的接口1
 success: function(data, status) {
 if (data.errcode==0) {
 alert("已发送");
 $(".code1").attr("disabled", "disabled");
 $(".code1").css("background", "#b4b2b3");

//下面就是实现倒计时的效果代码
 var d = new Date();
 d.setSeconds(d.getSeconds() + 59);
 var m = d.getMonth() + 1;
 var time = d.getFullYear() + '-' + m + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();

 var id = ".code1";
 var end_time = new Date(Date.parse(time.replace(/-/g, "/"))).getTime(),
 //月份是实际月份-1
 sys_second = (end_time - new Date().getTime()) / 1000;
 var timer = setInterval(function() {
 if (sys_second > 1) {
 sys_second -= 1;
 var day = Math.floor((sys_second / 3600) / 24);
 var hour = Math.floor((sys_second / 3600) % 24);
 var minute = Math.floor((sys_second / 60) % 60);
 var second = Math.floor(sys_second % 60);
 var time_text = '';
 if (day > 0) {
 time_text += day + '天';
 }
 if (hour > 0) {
 if (hour < 10) {
 hour = '0' + hour;
 }
 time_text += hour + '小时';
 }
 if (minute > 0) {
 if (minute < 10) {
 minute = '0' + minute;
 }
 time_text += minute + '分';
 }
 if (second > 0) {
 if (second < 10) {
 second = '0' + second;
 }
 time_text += second + '秒';
 }
 $(id).text(time_text);

 } else {
 clearInterval(timer);
 $(".code1").attr("disabled", false);
 $(".code1").text('获取绑定验证码');
 $(".code1").css("background", "#eee");
 }
 },
 1000); 
 
 }else{
 alert("发送失败，请再试一次。");
 }
 },
 error: function(data, status) {
 alert(status);
 
 }
 });
 
 });
 
// 发送到服务器
//验证验证码和手机发送的验证码是否一致
$('.demand').click(function(){
 $.ajax({
 type: 'GET',
 url: "",
 success: function(data, status) {
 if (data.errcode==0) {
 //向服务器提交信息
 $.ajax({
 type: 'POST',
 url: "向服务器提交的信息接口",
 data: JSON.stringify({     //data这里根据接口的数据需求去写
 "project_id": pid,
 "phone": mobile,
 "device":d
 }),
 success: function(data, status) {
 if (data.errcode==0) {
// $('.page1').hide();
// $('.page2').show();
 }else{
 alert("提交失败,请在尝试一次!");
 }
 },
 error: function(data, status) {
 alert(data.errMsg);
 }
 });
 }else{
 alert("验证码不正确！");
 }
 },
 error: function(data, status) {
 alert(status);
 }
 });
 
 });
 })